package com.qyer.search.DeserializerProcessor;

import com.qyer.log.WarningLogger;
import com.qyer.search.filter.AbstractFilter;
import com.qyer.search.filter.AbstractIDFilter;
import com.qyer.search.model.SearchParameterEntity;
import com.qyer.search.model.aggregation.AggregationProduct;
import com.qyer.search.model.aggregation.AggregationRegular;
import com.qyer.search.model.result.SearchEntity;
import com.qyer.search.utils.ModelUtils;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * Created by tangzheng on 16/8/11.
 */
public class CacheAllProcessor implements Callable<SearchEntity> {
  private SearchParameterEntity sp;
  private List<String> resultStringList;
  private int result_mode;
  private List<AbstractIDFilter> filters;
  private AggregationProduct productCensus;
  private AggregationRegular regular;
  private long submitTime = 0;

  public CacheAllProcessor(SearchParameterEntity sp, List<String> resultStringList,
                                      int result_mode, List<AbstractIDFilter> filters,
                                      AggregationProduct productCensus, AggregationRegular regular,
                                      long submitTime) {
    this.sp = sp;
    this.resultStringList = resultStringList;
    this.result_mode = result_mode;
    this.filters = filters;
    this.productCensus = productCensus;
    this.regular = regular;
    this.submitTime = submitTime;
  }

  @Override public SearchEntity call() throws Exception {

    //System.out.println("SearchEntity Call all go~");
    long t1 = System.currentTimeMillis();
    WarningLogger.logWarning("s:" + this.submitTime + ":e:" + System.currentTimeMillis(), sp);
    SearchEntity searchEntity = ModelUtils.packageAllSTG(sp, resultStringList, filters, regular, productCensus, result_mode);
    return searchEntity;
  }
}
